Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CPU/Mem Stats compatibility for Podman with cgroup v2 #93

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

gorynychzmey
Copy link

@gorynychzmey gorynychzmey commented Jan 18, 2022

Podman's realisation of Docker API uses cpuacct for per_cpu and online_cpus, which are only available with cgroup v1.
Also Podman realisation of Docker API with cgroup v2 doesn't provides memory_stats.stats.

Podman's realisation of Docker API uses cpuacct for per_cpu and online_cpus, which are only available with cgroup v1.
@gorynychzmey gorynychzmey changed the title CPU Stats compatibility for Podman with cgroup v2 CPU/Mem Stats compatibility for Podman with cgroup v2 Jan 18, 2022
@ualex73
Copy link
Owner

ualex73 commented Jan 19, 2022

Question, you added a new "if "stats" in raw["memory_stats"]:" for the version1904 code. Now that "stats" must exist before that part of the code will be executed, what is the scenario where that will happen? If it is for podman, then we should add some code to get the correct "cache" value (with the new code, it is set to 0)

@gorynychzmey
Copy link
Author

gorynychzmey commented Jan 19, 2022

As I understood, cgroup v2 doesn't report cache stats at all, or at least Podman API realisation with cgroup v2 doesn't report it, The previous code assumed that memory_stats.stats to get cache value would be always reported, so I've added a check to be sure that in situation when memory_stats.stats are not present the code will run correctly and the cache will be assumed equal to 0 - that is exactly the case with Podman+cgroup_v2.

cgroup v2 seems to be general less reportive as v1, but I would like to have container stats at least partially without need to set up older version of cgroup. I said "partially" because f.e. Podman API assumes memory_stats.limit to be equal MAXINT64 instead of total available memory, so memory_stats.usage_percent will be just always equals to 0. Fortunately containers_memory_percentage uses total available memory as a basis, not the memory_stats.limit.

@scottsweb
Copy link

I tested these fixes on a Podman install and I see far less errors now.

I was seeing errors every few seconds before and now I just get an occasional Container not available anymore (3) (DockerError(900, 'Cannot connect to Docker Engine via unix:///run/docker.sock [[Errno 32] Broken pipe]')).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants